<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>linen</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="line.html" title="line" />
    <link rel="next" href="linenr.html" title="linenr" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">linen</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="line.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="linenr.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="linen"></a>
      <div class="titlepage"></div>
      <a id="IndexLinen" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">linen</span>
        </h2>
        <p>linen — 
      Applies a straight line rise and decay pattern to an input amp signal.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118721376"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>linen</em></span> -- apply a straight line rise and decay pattern to an input amp signal.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118723072"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>linen</strong></span> xamp, irise, idur, idec</pre>
        <pre class="synopsis">kres <span class="command"><strong>linen</strong></span> kamp, irise, idur, idec</pre>
      </div>
      <div class="refsect1">
        <a id="idp118799680"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>irise</em></span> -- rise time in seconds. A zero or negative value signifies no rise modification.
    </p>
        <p>
      <span class="emphasis"><em>idur</em></span> -- overall duration in seconds. A zero or negative value will cause initialization to be skipped.
    </p>
        <p>
      <span class="emphasis"><em>idec</em></span> -- decay time in seconds. Zero means no decay. An <span class="emphasis"><em>idec</em></span> &gt; <span class="emphasis"><em>idur</em></span> will cause a truncated decay.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118804064"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kamp, xamp</em></span> -- input amplitude signal.
    </p>
        <p>
      Rise modifications are applied for the first <span class="emphasis"><em>irise</em></span> seconds, and decay from time <span class="emphasis"><em>idur - idec</em></span>. If these periods are separated in time there will be a steady state during which <span class="emphasis"><em>amp</em></span> will be unmodified. If <span class="emphasis"><em>linen</em></span> rise and decay periods overlap then both modifications will be in effect for that time. If the overall duration <span class="emphasis"><em>idur</em></span> is exceeded in performance, the final decay will continue on in the same direction, going negative.
    </p>
        <p>
      </p>
        <div class="mediaobject">
          <img src="images/linen.jpg" alt="[Envelope generated by the linen opcode]" />
          <div class="caption">
            <p>Envelope generated by the <span class="emphasis"><em>linen</em></span> opcode</p>
          </div>
        </div>
        <p>
    </p>
        <p>
      </p>
        <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Note">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Note]" src="images/note.png" />
              </td>
              <th align="left">Note</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>A common error with this opcode is to assume that the value of
          0 is the held after the envelope has finished at
          <span class="emphasis"><em>idur</em></span>. <span class="emphasis"><em>linen</em></span> does not
          automatically end or stop at the end of the duration given.
          If your note length is longer than <span class="emphasis"><em>idur</em></span>
          seconds, <span class="emphasis"><em>kres</em></span> (or <span class="emphasis"><em>ares</em></span>)
          will not come to rest at 0, but will instead continue to fall
          with the same rate. If a decay and then hold is required then
          the <a class="link" href="linseg.html" title="linseg"><em class="citetitle">linseg</em></a> opcode should be considered instead.
        </p>
              </td>
            </tr>
          </table>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118817424"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the linen opcode. It uses the file <a class="ulink" href="examples/linen.csd" target="_top"><em class="citetitle">linen.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp118819280"></a>
          <p class="title">
            <strong>Example 420. Example of the linen opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac    <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o linen.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1

<span class="oblock">instr</span> 1
<span class="comment">; p4=amp</span>
<span class="comment">; p5=freq</span>
<span class="comment">; p6=attack time</span>
<span class="comment">; p7=release time</span>
ares <span class="opc">linen</span>  p4, p6, p3, p7 
asig <span class="opc">poscil</span> ares, p5, 1    
     <span class="opc">outs</span>   asig, asig     
                                         
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span>1   0    4096 10 1      <span class="comment">; sine wave</span>

<span class="comment">;ins strt dur amp  freq attack release</span>
<span class="stamnt">i</span>1   0    1   .5   440   0.5    0.7
<span class="stamnt">i</span>1   1.5  1   .2   440   0.9    0.1
<span class="stamnt">i</span>1   3    1   .2   880   0.02   0.99
<span class="stamnt">i</span>1   4.5  1   .2   880   0.7    0.01
<span class="stamnt">i</span>1   6    3   .7   220   0.5    0.5
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp118823568"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="envlpx.html" title="envlpx"><em class="citetitle">envlpx</em></a>,
      <a class="link" href="envlpxr.html" title="envlpxr"><em class="citetitle">envlpxr</em></a>,
      <a class="link" href="linenr.html" title="linenr"><em class="citetitle">linenr</em></a>
    </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="line.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="linenr.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">line </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> linenr</td>
        </tr>
      </table>
    </div>
  </body>
</html>
